﻿
using System;
using System.Collections.Generic;
/// <summary>
///  Generic Hierarchy Finite State Machine,
///  Hfsm is also a State of its super fsm
/// </summary>
/// <typeparam name="EntityController">may be playerController, enemyController, etc</typeparam>
public abstract class HFsm<StateId, EntityController> : State<StateId> {
	protected EntityController _controller;

	protected HFsm(EntityController controller, StateId stateName, State<StateId> superFSM, StateFactory<StateId> factory) :
		base(stateName, superFSM, factory) {
		_controller = controller;
	}

	/// <summary>
	/// May be subFSMs, not only states, 
	/// to some extents, the fsm is also a state.
	/// </summary>
	public List<State<StateId>> States { get; set; }

	/// <summary>
	/// Decide which SubState to run
	/// </summary>
	public override void Enter() {
		foreach (var s in States) {
			if (s.ConditionToSelf()) {
				CurState = s;
				break;
			}
		}
	}

}

